package com.example.demo.controller.user;


import com.example.demo.service.user.UserService;
import com.example.demo.vo.ResultVO;
import com.example.demo.vo.StrategyVO;
import com.example.demo.vo.task.TaskVO;
import com.example.demo.vo.user.UserRoleVO;
import com.example.demo.vo.user.UserVO;
import com.example.demo.vo.user.WorkerTaskVO;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/user")
public class UserController {
    @Resource
    private UserService userService;

    @PostMapping("/register")
    public ResultVO<UserVO> register(@RequestBody UserVO userVO){
        return userService.userRegister(userVO);
    }

    @PostMapping("/login")
    public ResultVO<UserRoleVO> login(@RequestBody UserVO userVO){
        return userService.userLogin(userVO);
    }

    @GetMapping("/getTakeTaskState")
    public ResultVO<WorkerTaskVO> getTakeTaskState(@RequestParam("username") String username,@RequestParam("tid")int tid){
        return userService.getTakeTaskState(username,tid);
    }

    @PostMapping("/setTakeTaskState")
    public ResultVO<WorkerTaskVO> setTakeTaskState(@RequestBody WorkerTaskVO workerTaskVO){
            return userService.setTakeTaskState(workerTaskVO);
    }

    @PostMapping("/submitStrategy")
    public ResultVO<StrategyVO> submitStrategy(@RequestBody StrategyVO strategyVO){
        return userService.submitStrategy(strategyVO);
    }

    @GetMapping("/getCurrentStrategy")
    public ResultVO<StrategyVO> getCurrentStrategy(){
        return userService.getCurrentStrategy();
    }

    @GetMapping("/getRecommendTaskByUser")
    public ResultVO<List<TaskVO>> getRecommendTaskByUser(@RequestParam("username") String username){
        return userService.getRecommendTaskByUser(username);
    }

    @RequestMapping ("/test")
    public String test(){
        return userService.test();
    }




}
